import { stringify } from 'qs';
import request from '../../common/utils/request';
import { Constants } from '../../common/constant/constants';

//登录
export async function login(params) {
    return request(Constants.JAVA_URL+'/sys/login', {
        method: 'POST',
        body: params,
    });
}
//登出
export async function logout() {
    return request(Constants.JAVA_URL+'/sys/logout');
}
//获取登录的账号的权限
export async function getPermissions() {
    return request(Constants.JAVA_URL+'/sys/user/permissions');
}

//用户管理
export async function queryUsers(params) {
    return request(Constants.JAVA_URL+`/sys/user/list?${stringify(params)}`);
}

export async function queryUserInfo(params) {
    return request(Constants.JAVA_URL+`/sys/user/info/${params}`);
}

export async function saveUser(params) {
    return request(Constants.JAVA_URL+'/sys/user/save', {
        method: 'POST',
        body: params,
    });
}

export async function updateUser(params) {
    return request(Constants.JAVA_URL+'/sys/user/update', {
        method: 'POST',
        body: params,
    });
}

export async function deleteUser(params) {
    return request(Constants.JAVA_URL+'/sys/user/delete', {
        method: 'DELETE',
        body: params,
    });
}

//获取当前登录用户
export async function queryCurrentUser() {
    return request(Constants.JAVA_URL+`/sys/user/info`);
}

//导出
export async function exportUser() {
    return request(Constants.JAVA_URL+'/sys/user/export');
}